package com.controll.jaxb;

import java.io.FileInputStream;
import java.io.InputStream;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import com.bean.jaxb.userList.UserListVo;

public class parseXml2BeanList {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {  
			
			InputStream is = new FileInputStream( "data/userList.xml" );
			double startTime,endTime,totTime;			
			//URL url = new URL("http://192.168.1.72/SpPushUser?type=0&acc=&group_id=&status=0&page=1&pagecnts=25&staff=testAdmin&location=0:0:0:0:0:0:0:1");
			
			startTime = System.currentTimeMillis();
			
			JAXBContext jaxbContext = JAXBContext.newInstance(UserListVo.class);  
			Unmarshaller um = jaxbContext.createUnmarshaller();  
			UserListVo userList = new UserListVo();
			userList = (UserListVo)um.unmarshal(is);  
			System.out.println(userList.getUserList().size());
//			for(int i=0; i<userList.getUserList().size(); i++){				
//				System.out.println(userList.getUserList().get(i).getName());
//			}
			
			endTime = System.currentTimeMillis();
			totTime = endTime - startTime;
			System.out.println("Using Time: " + totTime/1000+" sec");
			
//			for(int i=0; i<userList.getUserList().size(); i++){
//				System.out.println(userList.getUserList().get(i).getName());
//			}
									
		}catch (JAXBException e) {  
			e.printStackTrace();
        } catch (Exception e) {			
			e.printStackTrace();
		}  
	}

}
